<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>订单详情</title>
<link rel="stylesheet" type="text/css" href="/style/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/swiper.min.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/xshop.css?ver=20170916" />
<link rel="stylesheet" type="text/css" href="/style/css/fu.shop.css"/>
<script src="/style/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/xShop.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
<link type="text/css" rel="stylesheet" href="/style/css/sweet-alert.css">

<style>
.outer{position:absolute;left:0;width:100%;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;box-orient:vertical;-webkit-flex-direction:column;flex-direction:column}
.inner{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;background-color:#f1f1f1;overflow-y:scroll;-webkit-overflow-scrolling:touch; margin-bottom: 1.2rem;}
.inner.iPhoneX
{
    margin-bottom: 1.6rem;
}
.opacity{-webkit-animation:opacity .3s linear;animation:opacity .3s linear}
@-webkit-keyframes opacity{0%{opacity:0}
100%{opacity:1}
}
@keyframes opacity{0%{opacity:0}
100%{opacity:1}
}
.popmask{position:fixed;width:100%;height:100%;background:rgba(0,0,0,.8);left:0;top:0;z-index:999;display: none;}
.popexp{position:fixed;width:80%;height:70%;padding:10% 5%;left:5%;top:5%;background:#fff;z-index:1000;overflow-x:hidden;overflow-y:auto;display: none;}
.popexp .name{float:left;width:100%;height:auto;color:#999;padding-bottom:.3rem;line-height:.4rem;font-size:.26rem;border-bottom:1px solid #ccc;margin-bottom:.5rem}
.popexp ul{float:left;width:100%;height:auto;list-style:none}
.popexp ul li{border-left:1px solid #ccc;height:auto;background:#fff;color:#999;float:left;width:80%;padding-left:.5rem;font-size:.26rem}
.popexp ul li div{position:absolute;width:.2rem;height:.2rem;border-radius:.2rem;background:#ccc;left:.28rem}
.popexp ul li.curr{color:#73C887}
.popexp ul li.curr div{position:absolute;width:.25rem;height:.25rem;border-radius:.25rem;background:#73C887;border:.05rem solid #D1ECD9;left:.22rem}
.popexp ul li p{padding-top:.2rem}
.popexp ul li i{float:left;width:100%;height:1px;background:#ccc;margin:.2rem 0}
.popclose{position: fixed; bottom: 1rem; text-align: center; width: 100%; height: .5rem; z-index: 1000; display: none;}
.popclose img{width: auto; height: .8rem;}
</style>
</head>
<body>
<div class="outwrap">
		<!--top-->	
  	<!-- <div class="topbar clearfix topvh">
    <a href="/user/index" class="btn-back">
        <i class="ico-back"></i><span>返回</span>
    </a>
			<h2 class="title">订单</h2>
		</div> -->

    <div class="meinner-adr-add">

    <?php if(empty($this->data['data'])):?>
      <div class="order-none">
        <i class="ico"><img src="/style/images/noorder1.png"/></i>       
        <p class="p1">您还没有相关的订单</p>
        <p class="p2">可以去看看有哪些想买的</p>
        <a href="/" class="goshop">去选购</a>
      </div>
      <?php else:?>
        <div class="outer ord-main" style="margin-top:-1.55rem;">
         <div class="inner">
         <div id="thelist">
        
        <div class="ord-list">
      <div class="bh"><p>订单编号：<?=$this->data['data']['order_sn']?></p>
      </div>
      <div class="info">
        <dl><dt>状态：</dt><dd class="state"><span><?=$this->data['data']['new_status']?></span></dd></dl>
        <dl><dt>时间：</dt><dd><?=date("Y-m-d H:i:s",$this->data['data']['add_time'])?></dd></dl>
        <dl><dt>优惠券抵用：</dt><dd>￥<?=$this->data['data']['discount_fee'];?></dd></dl>
        <dl><dt>硒米消费：</dt><dd><?=($this->data['data']['ximi_fee']*1);?></dd></dl>
        <dl><dt>金花抵用：</dt><dd>￥<?=($this->data['data']['gold_fee']*1);?></dd></dl>
        <dl><dt>代金券抵用：</dt><dd>￥<?=$this->data['data']['coupon_fee'];?></dd></dl>
        <dl><dt>收货人：</dt><dd><?=$this->data['data']['consignee']?></dd></dl>
        <dl><dt>电话：</dt><dd><?=$this->data['data']['mobile']?></dd></dl>
        <dl><dt>地址：</dt><dd><?=$this->data['region'][$this->data['data']['province_id']]?><?=$this->data['region'][$this->data['data']['city_id']]?><?= !empty($this->data['data']['county_id'])?$this->data['region'][$this->data['data']['county_id']]:'';?><?=$this->data['data']['address']?></dd></dl> 
         <?php if(!empty($this->data['data']['remark'])){?><dl><dt>备注：</dt><dd style="color:#f6b804"><?=$this->data['data']['remark']?></dd></dl><?php }?> 
      </div>
      <div class="splist">
        <ul>
        <?php if(!empty($this->data['data']['goods'])){

            ?>
        <?php foreach($this->data['data']['goods'] as $key=>$vv):
          $num += $vv['goods_number'];
          ?>
          <li class="clearfix">
          <a href="/index/goodsdetail?goods_id=<?=$vv['goods_id']?>">
            <div class="img"><img src="<?=$this->data['docs'][$vv['thumb_docid']]?>"/></div>
            <div class="goods_msg clearfix">
              <h2><?=$vv['goods_name']?><?=$vv['attr_str']?><?//=$vv['refund_status'];?></h2>
              <div class="prc">
                <span><?php
                if($vv['goods_price']>0)
                {
                    echo '￥'.$vv['goods_price'];
                }
                elseif($vv['ximi_price']>0)
                {
                    echo ($vv['ximi_price']*1).'硒米';
                }
                ?></span><em>数量 <?=$vv['goods_number']?></em>                
              </div>
            </div>
            </a>
            <?php
            if($this->data['data']['order_status'] ==7 || $this->data['data']['order_status']==8){
            
                echo '';
            }
            else if($vv['shipping_id']!=""  && ($vv['return_goods_status'] ==0 || $vv['return_goods_status'] ==7) )
            {
              // echo '<div class="express"><div onClick="_order_return_goods('.$this->data['data']['order_id'].','.$vv['rec_id'].')">申请退货</div></div>';
            
            }else if($vv['return_goods_status'] == 1){
                
                echo '<div class="express"><div>等待退货审核</div></div>';
            }else if($vv['return_goods_status'] == 2){
                
                echo '<div class="express"><div onClick="retun_addr('.$vv['rec_id'].')">填写退货信息</div></div>';
            }else if($vv['return_goods_status'] == 3){
                
                echo '<div class="express"><div>待收货待退款</div></div>';
            }else if($vv['return_goods_status'] == 4){
                
                echo '<div class="express"><div>已收货待退款</div></div>';
            }else if($vv['return_goods_status'] == 5){
                
                echo '<div class="express"><div>已退款</div></div>';
            }else if($vv['return_goods_status'] == 6){
                
                echo '<div class="express"><div>退款失败</div></div>';
            }
            else if(($vv['refund_status']==0 || $vv['refund_status']==5) && $this->data['data']['pay_status'] > 0  && $vv['shipping_id'] =="" && $vv['can_not_reback'] == 0 && $this->data['data']['shipping_status']==0){
                
               /* echo '<div class="express"><div onClick="_order_refund('.$this->data['data']['order_id'].','.$vv['rec_id'].')">申请退款</div></div>';*/
                
            }else if($vv['refund_status'] == 1){
                
                echo '<div class="express"><div>等待退款审核</div></div>';
            }else if($vv['refund_status'] == 2){
                
                echo '<div class="express"><div>审核通过待退款</div></div>';
            }else if($vv['refund_status'] == 3){
                
                echo '<div class="express"><div>已退款</div></div>';
            }else if($vv['refund_status'] == 4){
                
                echo '<div class="express"><div>退款失败</div></div>';
            }
            ?>

              <?php

              if(count($this->data['data']['goods'])-1 == $key){
                  if($this->data['data']['pay_status'] ==2 && $this->data['data']['order_status'] && $this->data['data']['shipping_status']==0){

                      echo '<div class="express"><div onClick="_order_refund('.$this->data['data']['order_id'].','.$vv['rec_id'].')">申请退款</div></div>';

                  }
              }
              ?>
          </li>
       <?php endforeach;?>

          <?php }?>

        </ul>       
      <div class="gongji clearfix">
        <span class="num">共<?=$num;?>件商品</span>
        <span class="num">运费: ￥<?=$this->data['data']['shipping_fee'];?></span>
        <span class="price">合计: ￥<?=$this->data['data']['pay_fee'];?></span>
       </div>
        
      </div>
    </div>
   
      </div>
      </div>
      </div>
      <?php endif;?>
  </div>
  

</div>
<div class="popmask"></div>
<div class="popexp">
  <div class="name">--</div>
  <ul></ul>
</div>
<div class="popclose"><img src="/style/images/close.png"></div>

<script type="text/javascript">
function isIphoneX(){
    return /iphone/gi.test(navigator.userAgent) && (screen.height == 812 && screen.width == 375)
}    
$(document).ready(function(e) {
    // 查看物流信息
 
  
    // 判断iPhoneX
    if(isIphoneX())
    {
        $(".foot-menu,.inner").addClass("iPhoneX");
    }
});

//申请退款
function _order_refund(oid,cid)
{
   if(oid>0 && cid>0){
	  
	    swal({
	        title: "确定申请退款吗？",
	        type: "warning",
	        timer: 30000,
	        showCancelButton: true,
	        confirmButtonText: "确定",
	        cancelButtonText: "取消",
	        closeOnConfirm: false,
	        closeOnCancel: true
	    }, function(isConfirm) {
	        if (isConfirm) {
 	            $.ajax({
	                type: "POST",
	                url: "/order/ajax",
	                data: {
	                    "act": "order_refund",
	                    "order_id": oid,
	                    "rec_id":cid,
	                    "mr": Math.random()
	                },
	                dataType: "json",
	                success: function(data) {
	                    if (data.code == 200) {
	                        swal(data.msg, false, "success");
	                        setTimeout(function() {
	                        	window.location.reload();
	                        }, 2100);
	                    } else {
	                        swal(data.msg+'['+data.code+']', false, "error");
	                    }
	                }
	            }); 
	        }
	    });
	}
	
}
//申请退货
//function _order_return_goods(oid,cid){
//
//    swal({
//        title: "确定申请退货吗？",
//        type: "warning",
//        timer: 30000,
//        showCancelButton: true,
//        confirmButtonText: "确定",
//        cancelButtonText: "取消",
//        closeOnConfirm: false,
//        closeOnCancel: true
//    }, function(isConfirm) {
//        if (isConfirm) {
//	            $.ajax({
//                type: "POST",
//                url: "/order/ajax",
//                data: {
//                    "act": "order_return_goods",
//                    "order_id": oid,
//                    "rec_id":cid,
//                    "mr": Math.random()
//                },
//                dataType: "json",
//                success: function(data) {
//                    if (data.code == 200) {
//                        swal(data.msg, false, "success");
//                        setTimeout(function() {
//                        	window.location.reload();
//                        }, 2100);
//                    } else {
//                        swal(data.msg+'['+data.code+']', false, "error");
//                    }
//                }
//            }); 
//        }
//    });
//}

function retun_addr(cid){
	location.href="/order/apply_return_goods?rec_id="+cid;
	
}
	

</script>
</body>
</html>